GPU=0
CUDNN=0
OPENCV=0
OPENMP=0
DEBUG=0

ARCH = 	-gencode arch=compute_30, code=sm_30 \
		-gencode arch=compute_35, code=sm_35 \
		-gencode arch=compute_50, code=[sm_50, compute_50] \
		-gencode arch=compute_52, code=[sm_52, compute_52]

VPATH=./:./model:./utils
EXEC=cform
ALIB=cform.a

OBJDIR=./obj/
CC=gcc
CPP=g++
NVCC=NVCC
AR=ar
ARFLAGS=rcs
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON=-I./ -I./utils -I./multiple -I./model
CFLAGS=-Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC

ifeq ($(OPENMP), 1) 
CFLAGS+= -fopenmp
endif

ifeq ($(DEBUG), 1) 
OPTS=-O0 -g
endif

CFLAGS+=$(OPTS)

EXECOBJA= main.o mnist.o data_loader.o linear_layer.o utils.o image.o blas.o gemm.o activations.o \
 batchnorm_layer.o col2im.o convolutional_layer.o cost_layer.o maxpool_layer.o softmax_layer.o cform.o \
 adaptive_avg_pool.o concat_layer.o conv_transpose2d_layer.o netwok.o option_list.o parser.o\
 pruning.o quantization.o rnn_layer.o split_layer.o list.o

EXECOBJ=$(addprefix $(OBJDIR), $(EXECOBJA))
DEPS=$(wildcard *.h)
$(info "here add the debug info ${EXECOBJ}")

all: obj $(EXEC)

$(EXEC): $(EXECOBJ)
	$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)

$(OBJDIR)%.o: %.c $(DEPS)
	$(CC) $(COMMON) $(CFLAGS) -c $< -o $@

obj:
	mkdir -p obj

.PHONY: clean

clean:
	rm -rf $(OBJS) $(EXEC) $(EXECOBJ) $(OBJDIR)/*